package com.wendy.thirdpartyaccess.wechat;

import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.ConnectionValues;
import org.springframework.social.connect.UserProfile;

/**
 * @author zhuwending
 */
public class WechatAdapter implements ApiAdapter<Wechat> {

    private String openId;

    WechatAdapter() {
    }

    WechatAdapter(String openId) {
        this.openId = openId;
    }

    @Override
    public boolean test(Wechat wechat) {
        return true;
    }

    @Override
    public void setConnectionValues(Wechat wechat, ConnectionValues values) {
        WechatUserInfo userInfo = wechat.getUserInfo(openId);
        values.setProviderUserId(userInfo.getOpenid());
        values.setDisplayName(userInfo.getNickname());
        values.setImageUrl(userInfo.getAvatar());
    }

    @Override
    public UserProfile fetchUserProfile(Wechat wechat) {
        return null;
    }

    @Override
    public void updateStatus(Wechat wechat, String s) {

    }
}
